package com.bicon.botu.mall.component.rpc.service;

import com.bicon.botu.core.base.common.controller.BaseController;
import com.bicon.botu.core.base.common.entity.BaseResult;
import com.bicon.botu.mall.component.service.IInformationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

/**
 * 系统消息前端控制器
 *
 * @author 张凡
 * @date 2017/12/06 14:36
 */
@Service
public class InformationRpcService extends BaseController {
    @Autowired
    IInformationService iInformationService;

    /**
     * 保存系统消息
     *
     * @param appId      app标识
     * @param userIdJson 多个用户id
     * @param module     模块
     * @param business   业务
     * @param title      标题
     * @param content    内容
     * @param headline   首页标题
     * @param push       推送，0-不推送，1-推送
     * @return
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public BaseResult save(@RequestParam("appId") String appId,
                           @RequestParam("userIdJson") String userIdJson,
                           @RequestParam("module") String module,
                           @RequestParam("business") String business,
                           @RequestParam("title") String title,
                           @RequestParam("content") String content,
                           @RequestParam("headline") String headline,
                           @RequestParam("push") String push) {
        if (StringUtils.isAnyBlank(userIdJson, module, business, title, content, headline)) {
            return sendResult400();
        }
        iInformationService.save(appId, userIdJson, module, business, title, content, headline, push);
        return sendResult200();
    }
}
